//
//  LBSlidePopViewController.m
//  TEXT
//
//  Created by mac on 2024/8/18.
//  Copyright © 2024 刘博. All rights reserved.
//

#import "LBSlidePopViewController.h"
#import "LBSlidePopView.h"
#import "LBFunctionTestHeader.h"
#import "LBview.h"

@interface LBSlidePopViewController () <UITableViewDelegate, UITableViewDataSource, LBSlidePopViewDelegate>

@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) LBSlidePopView *slideView;

@end

@implementation LBSlidePopViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setUpUI];
    [self.tableView reloadData];
    // Do any additional setup after loading the view.
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    [self.navigationController setNavigationBarHidden:true animated:animated];
}

- (void)setUpUI
{
    self.view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.4];
    CGFloat top = SCREEN_HEIGHT - 400;
    self.viewContent = [[LBview alloc] initWithFrame:CGRectMake(0, top, SCREEN_WIDTH, 400)];
    self.viewContent.backgroundColor = [UIColor purpleColor];
    self.view.backgroundColor = [UIColor whiteColor];
    
    //半透明背景
    self.viewDismiss = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    self.viewDismiss.alpha = 0.0;
    self.slideView = [[LBSlidePopView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) contentView:self.viewContent maskView:self.viewDismiss delegate:self];
    self.view = self.slideView;
    [self.slideView addGestureRecognizer:self.slideView.tapGesture];
    self.view.backgroundColor = [UIColor clearColor];
    self.view.window.backgroundColor = [UIColor clearColor];
    [self.viewContent addSubview:self.tableView];
    
    self.slideView.scrollView = self.tableView;
}

#pragma mark - UITableViewDelegate, UITableViewDataSource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 100;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 40;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"kkk"];
    return cell;
}

#pragma mark - LBSlidePopViewDelegate

- (void)slideDismiss:(NSString *)source
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

#pragma mark - lazy load

- (UITableView *)tableView
{
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 400) style:UITableViewStylePlain];
        [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"kkk"];
        _tableView.delegate = self;
        _tableView.dataSource = self;
    }
    return _tableView;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
